<template>
  <NuxtLayout>
    <NuxtPage />
  </NuxtLayout>
</template>

<script setup>
const route = useRoute();
const config = useRuntimeConfig();

useHead({
  title: "西科院",
  meta: [
    { name: "description", content: "这是您的企业官网介绍页面。" },
    { name: "viewport", content: "width=device-width, initial-scale=1" },
    { name: "keywords", content: "西科院, 教育, 在线学习，西班牙科技创新院" },
    { name: "author", content: "西科院团队" },
    { name: "theme-color", content: "#ffffff" },
  ],
  link: [
    { rel: "canonical", href: config.public.siteUrl + route.fullPath },
    { rel: "icon", type: "image/png", href: "/logo.png" },
  ],
  script: [
    // Organization + WebSite（全站一次即可）
    {
      type: "application/ld+json",
      children: JSON.stringify({
        "@context": "https://schema.org",
        "@type": "Organization",
        name: "西班牙科技创新院",
        url: config.public.siteUrl,
        logo: `${config.public.siteUrl}/logo.png`,
      }),
    },
    {
      type: "application/ld+json",
      children: JSON.stringify({
        "@context": "https://schema.org",
        "@type": "WebSite",
        url: config.public.siteUrl,
        potentialAction: {
          "@type": "SearchAction",
          target: `${config.public.siteUrl}/search?q={query}`,
          "query-input": "required name=query",
        },
      }),
    },
  ],
});

useSeoMeta({
  titleTemplate: (titleChunk) => (titleChunk ? `${titleChunk}｜西班牙科技创新院` : "西班牙科技创新院"),
  ogSiteName: "西班牙科技创新院",
  twitterCard: "summary_large_image",
  // 避免无描述页
  description: "西班牙科技创新院官网，聚焦科学研究、成果转化与行业资讯。",
});

import { onMounted } from "vue";
onMounted(() => {
  // 百度统计
  var _hmt = window._hmt || [];
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3ef73f43d4d8db3c8684068754e8be04";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);

  // Google Analytics
  var gaScript = document.createElement("script");
  gaScript.async = true;
  gaScript.src = "https://www.googletagmanager.com/gtag/js?id=G-BJWFJ02MZ7";
  document.head.appendChild(gaScript);

  gaScript.onload = function () {
    window.dataLayer = window.dataLayer || [];
    function gtag() {
      window.dataLayer.push(arguments);
    }
    gtag("js", new Date());
    gtag("config", "G-BJWFJ02MZ7");
    window.gtag = gtag;
  };
});
</script>
